home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / TextureBar.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  5.1 KB  |  188 lines

  1. //++timo TODO : the whole CTextureBar has to be modified for the new texture code
  2.  
  3. // TextureBar.cpp : implementation file
  4. //
  5.  
  6. #include "stdafx.h"
  7. #include "Radiant.h"
  8. #include "TextureBar.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CTextureBar dialog
  18.  
  19.  
  20. CTextureBar::CTextureBar()
  21.     : CDialogBar()
  22. {
  23.     //{{AFX_DATA_INIT(CTextureBar)
  24.     m_nHShift = 0;
  25.     m_nHScale = 0;
  26.     m_nRotate = 0;
  27.     m_nVShift = 0;
  28.     m_nVScale = 0;
  29.     m_nRotateAmt = 45;
  30.     //}}AFX_DATA_INIT
  31. }
  32.  
  33.  
  34. void CTextureBar::DoDataExchange(CDataExchange* pDX)
  35. {
  36.     CDialogBar::DoDataExchange(pDX);
  37.     //{{AFX_DATA_MAP(CTextureBar)
  38.     DDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate);
  39.     DDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale);
  40.     DDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift);
  41.     DDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale);
  42.     DDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift);
  43.     DDX_Text(pDX, IDC_HSHIFT, m_nHShift);
  44.     DDX_Text(pDX, IDC_HSCALE, m_nHScale);
  45.     DDX_Text(pDX, IDC_ROTATE, m_nRotate);
  46.     DDX_Text(pDX, IDC_VSHIFT, m_nVShift);
  47.     DDX_Text(pDX, IDC_VSCALE, m_nVScale);
  48.     DDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt);
  49.     //}}AFX_DATA_MAP
  50. }
  51.  
  52.  
  53. BEGIN_MESSAGE_MAP(CTextureBar, CDialogBar)
  54.     //{{AFX_MSG_MAP(CTextureBar)
  55.     ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift)
  56.     ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift)
  57.     ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale)
  58.     ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale)
  59.     ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate)
  60.     ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
  61.     ON_WM_CREATE()
  62.     ON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff)
  63.     //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CTextureBar message handlers
  68.  
  69. void CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult) 
  70. {
  71.     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  72.     *pResult = 0;
  73.  
  74.   if (pNMUpDown->iDelta < 0)
  75.     Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  76.   else
  77.     Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  78.   GetSurfaceAttributes();
  79. }
  80.  
  81. void CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult) 
  82. {
  83.     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  84.     // TODO: Add your control notification handler code here
  85.     
  86.     *pResult = 0;
  87.   if (pNMUpDown->iDelta < 0)
  88.     Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  89.   else
  90.     Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  91.   GetSurfaceAttributes();
  92. }
  93.  
  94. void CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult) 
  95. {
  96.     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  97.     // TODO: Add your control notification handler code here
  98.     
  99.     *pResult = 0;
  100.   if (pNMUpDown->iDelta < 0)
  101.       Select_ScaleTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  102.   else
  103.       Select_ScaleTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  104.   GetSurfaceAttributes();
  105. }
  106.  
  107. void CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult) 
  108. {
  109.     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  110.     // TODO: Add your control notification handler code here
  111.     
  112.     *pResult = 0;
  113.   if (pNMUpDown->iDelta < 0)
  114.       Select_ScaleTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  115.   else
  116.       Select_ScaleTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  117.   GetSurfaceAttributes();
  118. }
  119.  
  120. void CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult) 
  121. {
  122.     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  123.     *pResult = 0;
  124.   UpdateData(TRUE);
  125.   if (pNMUpDown->iDelta < 0)
  126.     Select_RotateTexture(abs(m_nRotateAmt));
  127.   else
  128.     Select_RotateTexture(-abs(m_nRotateAmt));
  129.   GetSurfaceAttributes();
  130. }
  131.  
  132.  
  133. void CTextureBar::OnSelectionPrint() 
  134. {
  135.     // TODO: Add your command handler code here
  136.     
  137. }
  138.  
  139. int CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  140. {
  141.     if (CDialogBar::OnCreate(lpCreateStruct) == -1)
  142.         return -1;
  143.     return 0;
  144. }
  145.  
  146.  
  147. void CTextureBar::OnBtnApplytexturestuff() 
  148. {
  149.   SetSurfaceAttributes();
  150. }
  151.  
  152. void CTextureBar::GetSurfaceAttributes()
  153. {
  154.   texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef;
  155.  
  156.   if (pt)
  157.   {
  158.     m_nHShift = pt->shift[0];
  159.     m_nVShift = pt->shift[1];
  160.     m_nHScale = pt->scale[0];
  161.     m_nVScale = pt->scale[1];
  162.     m_nRotate = pt->rotate;
  163.     UpdateData(FALSE);
  164.   }
  165. }
  166.  
  167. //++timo implement brush primitive here
  168. void CTextureBar::SetSurfaceAttributes()
  169. {
  170.   if (g_ptrSelectedFaces.GetSize() > 0)
  171.   {
  172.       if (g_qeglobals.m_bBrushPrimitMode)
  173.     {
  174.           Sys_Printf("Warning : brush primitive mode not implemented in CTextureBar");
  175.     }
  176.     face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
  177.  
  178.       texdef_t* pt = &selFace->texdef;
  179.     UpdateData(TRUE);
  180.     pt->shift[0] = m_nHShift;
  181.     pt->shift[1] = m_nVShift;
  182.     pt->scale[0] = m_nHScale; 
  183.     pt->scale[1] = m_nVScale; 
  184.     pt->rotate = m_nRotate; 
  185.     Sys_UpdateWindows(W_CAMERA);
  186.   }
  187. }
  188.